#include"processbar.h"
#include<unistd.h>
#include<string.h>

#define LENGTH 101
#define LABLE  '#'

void FlushProcess(double target,double current)
{
   const static char*sym="\\|-/";
   static int index=0;
   int len=strlen(sym);

   double rate=(current/target)*100.0;
   int n=rate;

   char bar[LENGTH];
   memset(bar,0,sizeof(bar));
   int i = 0;
   for(i = 0;i < n; i++)
   {
       bar[i]=LABLE;
   }
   printf("[%-100s][%.1lf%%][%c]\r",bar,rate,sym[index++]);
   index%=len;
   fflush(stdout);
   if(rate>=100.0)
   {
       printf("\n");
   }
}
